package com.huitone.gddw.service.impl.monitoring.warn;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huitone.gddw.dao.entity.InnormalEvent;
import com.huitone.gddw.dao.monitoring.warn.IInnormalEventRepDao;
import com.huitone.gddw.model.support.QueryPage;
import com.huitone.gddw.service.dto.monitoring.warn.InnormalEventRepDTO;
import com.huitone.gddw.service.monitoring.warn.IInnormalEventRepService;

/**
 * 预警汇总
 * @author wuluodan
 *
 */
@Service
public class InnormalEventRepService implements IInnormalEventRepService {

	@Autowired
	private IInnormalEventRepDao innormalEventRepDao;
	
	@Override
	public QueryPage<InnormalEventRepDTO> selectPage(QueryPage<InnormalEvent> page) {
		Map<String, Object> params = page.getParams();
		params.put("start", (page.getPageNo() - 1) * page.getPageSize() + 1);
		params.put("end", page.getPageNo() * page.getPageSize());
		
		List<InnormalEventRepDTO> result = innormalEventRepDao.selectPage(params);
		int totalCount = innormalEventRepDao.selectCount(params);
		
		QueryPage<InnormalEventRepDTO> queryPage = new QueryPage<InnormalEventRepDTO>();
		queryPage.setResult(result);
		queryPage.setPageNo(page.getPageNo());
		queryPage.setPageSize(page.getPageSize());
		queryPage.setTotalCount(totalCount);
		return queryPage;
	}

}
